package com.study.modules.saas.repository.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.study.modules.saas.repository.model.BillDO;
import com.study.modules.saas.repository.model.UserDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BillDao extends BaseMapper<BillDO> {


    @Result(property = "billId", column = "bill_no")
    @Select("select * from bill where order_id = #{orderId}")
    List<BillDO> selectBillsByOrderId(@Param("orderId") String orderId);

    @Results({@Result(property = "id",column = "id"),
    @Result(property = "uuid", column = "uuid"),
    @Result(property = "userUuid", column = "user_uuid"),
    @Result(property = "authUuid",column = "auth_uuid"),
    @Result(property = "billId", column = "bill_no"),
    @Result(property = "orderId", column = "order_id"),
    @Result(property = "orderDO",column = "order_id",javaType = UserDO.class,
            one = @One(select = ("com.study.modules.repository.dao.OrderDao.selectUserByOrderId")))})
    @Select("select * from bill where order_id = #{orderId}")
    BillDO selectBillByOrderId(@Param("orderId") String orderId);

}
